var options = new Array();

function OptionEntity(index){
	
	this.index = index;
	var self = this;
	
	this.create = function(){
		this.option_li = $('<li></li>');
		this.option_index = $('<span class = "btn red">'+ index +'</span>');
		this.option_text = $('<input name="content'+ index +'" type="text" class = "span5 m-wrap"/>');
		this.option_delete = $('<input type="button" value="删除" class = "btn yellow" />');
		
		this.option_li.append(this.option_index);
		this.option_li.append(this.option_text);
		this.option_li.append(this.option_delete);
		options.push(self);
	};
	
	this.deleteOption = function(){
		if(options.length < 3){
			return;
		}
		self.option_li.remove();
		for(var i = 0; i < options.length; i++){
			if((i+1) > self.index){
				options[i].index = options[i].index - 1;
				options[i].option_index.html(options[i].index);
				options[i].option_text.attr("name","content" + options[i].index );
			}
		}
		options.splice((self.index - 1), 1);
	};
	
	this.create();
	this.option_delete.on("click", self.deleteOption);
}